<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
   <script>
    // 一、通过递归计算阶层;
    function factorial(num){
        if(num==1){
            return 1;
        }
        return num*factorial(num-1);
    }
    var result=factorial(5);
    console.log(result);
    // 二、斐波那契额数列 1 1 2 3 5 8.....
    function sum(num){
        if(num==1||num==2){
            return 1;
        }
        return sum(num-1)+sum(num-2);
    }
    var res=sum(9);
    console.log(res);
    // 大循环/递归死循环
    // function sum(num){
    //     return sum(num);
    // }
    // var res=sum(5);
    // console.log(res);
   </script>
</body>
</html>